package cn.highedu.coolshark_product.controller;

import cn.highedu.coolshark_product.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志控制器类
 * 验证用户登录权限认证
 */
@RestController
@Slf4j
public class LogController {
    // 注入LogService
    @Autowired
    private LogService logService;

    /**
     * 具有ADMIN角色才能访问
     * @return
     */
    @GetMapping("/admin/log")
    public String adminLog() {
        log.debug("请求/admin/log");
        logService.adminLog();
        return "admin log";
    }

    /**
     * 具有MANAGER角色才能访问
     * @return
     */
    @GetMapping("/manager/log")
    public String managerLog() {
        log.debug("请求/manager/log");
        logService.managerLog();
        return "manager log";
    }

    /**
     * 具有sys:log:query权限才能访问
     * @return
     */
    @GetMapping("/log/query")
    public String queryLog() {
        log.debug("请求/log/query");
        logService.queryLog();
        return "query log";
    }

    /**
     * 具有sys:log:delete权限才能访问
     * @return
     */
    @GetMapping("/log/delete")
    public String deleteLog() {
        log.debug("请求/log/delete");
        logService.deleteLog();
        return "delete log";
    }
}
